<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateVMsgFeeTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('v_msg_fee', function (Blueprint $table) {
            $table->increments('id');
            $table->bigInteger('order_id')->default(0)->comment('订单ID');
            $table->uuid('driver_uuid')->comment('司机唯一标识');
            $table->tinyInteger('payment')->default(1)->comment('支付方式，1支付宝，2微信');
            $table->string('out_trade_no',64)->default('')->comment('商户支付单号');
            $table->integer('total_fee')->default(1)->comment('支付金额，单位：分');
            $table->string('subject',512)->default('')->comment('支付说明');
            $table->string('out_refund_no',32)->default('')->comment('商户退款单号');
            $table->string('refund_fee')->default(0)->comment('退款金额');
            $table->string('refund_desc',512)->default('')->comment('退款说明');
            $table->tinyInteger('pay_status')->default(10)->comment('状态，10待支付 20待支付确认 30已付款 40待退款 50退款确认 60已退款');
            $table->timestamps();
            $table->index('order_id', 'idx_order_id');
            $table->unique(['driver_uuid', 'order_id'], 'uniq_driver_order');
            $table->index('payment', 'idx_payment');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('v_msg_fee');
    }
}
